import { utils } from '@casstime/bricks';
import { IOption } from '@casstime/bricks/dist/src/components/select/DropdownList';

import { IProductDetail } from '../interfaces/IProductDetail';
import productDetail from '../../../assets/mockData/product-update/product-detail.json';
import qualityList from '../../../assets/mockData/product-update/product-quality-list.json';
import areaList from '../../../assets/mockData/product-update/address-list.json';
import categoryList from '../../../assets/mockData/product-update/category-list.json';

export interface IChainSelectOption extends IOption {
  children?: IChainSelectOption[];
}
/***
 * 获取商品详情
 * @param data 查询条件
 */
export const getProductDetail = async (
  data: IProductDetail
): Promise<IProductDetail> => {
  return productDetail || data;
};

/***
 * 获取品质列表
 */
export const getQualityList = async (): Promise<IOption[]> => {
  return qualityList;
};

/***
 * 获取地区列表
 */
export const getAreaList = async (): Promise<IChainSelectOption[]> => {
  return areaList;
};

/***
 * 获取品类列表
 */
export const getCategoryList = async (): Promise<utils.ITree[]> => {
  return categoryList;
};

/***
 * 保存商品信息
 */
export const saveProductInfo = async (
  data: IProductDetail
): Promise<IProductDetail> => {
  return data;
};
